home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
examples
/
exam15
/
class1.d
< prev
next >
Wrap
Text File
|
1995-09-27
|
3KB
|
128 lines
/*
*
* This source code is CONFIDENTIAL and
* PROPRIETARY to Algorithms Corporation. Unauthorized
* distribution, adaptation or use may
* be subject to civil and criminal penalties.
*
* Copyright (c) 1993 Algorithms Corporation
* 3020 Liberty Hills Drive
* Franklin, TN 37064
*
* ALL RIGHTS RESERVED.
*
*
*
*/
defclass Class1 {
char iName[30];
int iCode;
iData;
class:
int cNumInstances;
};
/* The New method is being modified to take an additional argument (in
addition to the default 'object self') of an int. This argument will
be used to initialize the iCode instance variable. Although Dynace
is able to overload generic names (we could use the same generic name
with different arguments) we will rename it for clairity. */
cmeth gNewWithInt(int code)
{
/* Declare an object which will hold the new instance object being
created. */
object obj;
/* Declare a pointer which will point to the instance variables
associated with the new instance. 'ivType' refers to a C
structure which looks like the instance variable structure
defined in the defclass. The name of the pointer must be 'iv'.
This is so Dynace knows how to access the instance variables
when they are refered to without the normal C iv-> construct. */
ivType *iv;
/* Increment the count as before. */
cNumInstances++;
/* Create the new instance object as before, only this time put it
in obj. */
obj = gNew(super);
/* Gain access to a pointer to the locally defined instance variables
associated with obj and assign it to iv. Note that this procedure,
which is required to access instance variables, is performed
automatically on the self object on instance methods. That is
why instance methods may directly access instance variables
associated with their self argument without the need for the
ivPtr or ivsPtr macros. */
iv = ivPtr(obj);
/* Since iv is correctly updated it is now safe to directly access
the instance variables associated with obj - update iCode with
the 'code' value passed to this method. */
iCode = code;
/* Since we are now through allocating and initializing the new
object, simply return it. */
return obj;
}
/* Create an instance method to allow an external program to access the
value in iCode in order to test our New method. */
imeth int gGetCode()
{
return iCode;
}
cmeth int gNumInstances()
{
return cNumInstances;
}
imeth object gDeepDispose, gDispose ()
{
cNumInstances--;
gDispose(super self);
return NULL;
}
imeth gSetName(char *name)
{
strcpy(iName, name);
return self;
}
imeth char * gGetName : get_name ()
{
return iName;
}
/*
*
* This source code is CONFIDENTIAL and
* PROPRIETARY to Algorithms Corporation. Unauthorized
* distribution, adaptation or use may
* be subject to civil and criminal penalties.
*
* Copyright (c) 1993 Algorithms Corporation
* 3020 Liberty Hills Drive
* Franklin, TN 37064
*
* ALL RIGHTS RESERVED.
*
*
*
*/